package com.feng.cloud.common.selector;

import com.feng.cloud.common.annotation.EnableRocketMq;
import com.feng.cloud.common.configure.EnhanceDelayMessageConfigure;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @ClassName EnhanceDelayMessageSelector
 * @Description TODO
 * @Author Better Feng
 * @Date 2021/1/30 16:57
 **/
public final class EnhanceDelayMessageSelector implements ImportSelector {

    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {
        AnnotationAttributes attributes = AnnotationAttributes.fromMap(annotationMetadata.getAnnotationAttributes(EnableRocketMq.class.getName(), true));
        assert attributes != null;
        if (attributes.getBoolean("enhanceDelayMessage")) {
            return new String[]{EnhanceDelayMessageConfigure.class.getName()};
        }
        return new String[0];
    }
}
